Add SHA-256 audit test vector for canonicalization protocol#17
Merged
Conversation
Protocol audit fixes:
1. src/canonicalize.ts — Add mandatory audit test vector
{"verb":"verify","family":"trust","version":"1.0.0"} with expected
canonical form and its SHA-256 digest to CANONICAL_TEST_VECTORS.
The audit protocol requires this known-vector to be computable and
tested. The canonical form is {"family":"trust","verb":"verify","version":"1.0.0"}
and its SHA-256 is 3c3e2e6f63b02c1dc4d0dc0f6429bcef5fe27f11059c856218a52a4f43f90e44.
2. test/canonicalize.test.ts — Add describe block that computes
SHA-256(canonicalize(audit_vector)) and asserts it equals the known
digest, enforcing determinism at the hash level.
3. package.json — Move `ethers` from dependencies to peerDependencies.
ethers is not imported by any src/ file; consumers supply their own
EnsProvider instance. Listing it as a production dependency forces
an unnecessary install on all consumers and misrepresents the API
contract. peerDependencies correctly documents that ethers >=6 is
required from the consumer's environment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a mandatory audit test vector to the canonicalization module to support protocol-level verification. It includes SHA-256 digest validation tests and improves test vector documentation with concrete hash values.
Key Changes
CANONICAL_TEST_VECTORSwith a SHA-256 digest field for the canonical form of{"verb":"verify","family":"trust","version":"1.0.0"}canonicalize.test.ts:\u4e16\u754c→世界)Implementation Details
The audit test vector locks the canonicalization algorithm to a concrete byte-level output. The SHA-256 digest (
3c3e2e6f63b02c1dc4d0dc0f6429bcef5fe27f11059c856218a52a4f43f90e44) serves as a protocol-level invariant—if canonicalization changes, this test will fail and signal that the protocol version must be bumped.The test includes detailed comments explaining the critical path requirement and the purpose of the audit vector in the protocol verification flow.
https://claude.ai/code/session_016igMwkFir2FkLQCHL6a34z